package com.cctc.rds.nrpc.api.connection.client;

import java.util.ArrayList;
import java.util.List;

public class ClientConnectionListenerProvider {
    private static class ClientConnectionListenerProviderHolder {
        private static final ClientConnectionListenerProvider INSTANCE = new ClientConnectionListenerProvider();
    }

    private ClientConnectionListenerProvider() {
        this.listeners = new ArrayList<>();
    }

    public static ClientConnectionListenerProvider getInstance() {
        return ClientConnectionListenerProviderHolder.INSTANCE;
    }

    private List<ClientConnectionListener> listeners;

    public synchronized void registry(ClientConnectionListener listener) {
        listeners.add(listener);
    }

    public synchronized void remove(ClientConnectionListener listener) {
        listeners.remove(listener);
    }

    public synchronized List<ClientConnectionListener> list() {
        return listeners;
    }

}
